import sys
from PyQt5.QtWidgets import QApplication, QWidget, QLabel, QLineEdit, QVBoxLayout

def init_widget(w:QWidget):
    w.setWindowTitle("单行输入框")
    w.resize(640, 480)
    
    layout = QVBoxLayout()
    username_edit = QLineEdit()
    
    username_edit.setPlaceholderText("请输入用户名")
    
    username_edit.setText("jackluo")
    
    username_edit.setMaxLength(12)
    
    layout.addWidget(username_edit)
    
    pwd_edit = QLineEdit()
    
    pwd_edit.setPlaceholderText("请输入密码")
    
    pwd_edit.setText("20020816")
    
    pwd_edit.setEchoMode(QLineEdit.Password)
    
    layout.addWidget(pwd_edit)
    
    w.setLayout(layout)
    
if __name__ == "__main__":
    app = QApplication(sys.argv)
    w = QWidget()
    init_widget(w)
    
    w.show()
    
    sys.exit(app.exec_())